<!DOCTYPE html>
{include file="public/link" /}
<blockquote class="layui-elem-quote">
    数据表编辑
</blockquote>
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">表名</label>
                <div class="layui-input-block">
                    <input type="text" name="table" lay-verify="required" placeholder="请输入表名" autocomplete="off"
                        class="layui-input" value="{$find.table}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="comment" lay-verify="required" placeholder="请输入备注" autocomplete="off"
                        class="layui-input" value="{$find.comment}">
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

{include file="public/script" /}

<script>
    layui.use(function () {
        let form = layui.form
        let $ = layui.$
        let layer = layui.layer

        // 提交事件
        form.on('submit(submit)', function (data) {
            let field = data.field; // 获取表单全部字段值
            let index = layer.load(0);
            $.post("", field, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {
                        icon: 1
                    }, function () {
                        parent.location.reload()
                    })
                } else {
                    layer.msg(res.msg)
                }
                layer.close(index)
            })

            return false; // 阻止默认 form 跳转
        });
    })
</script>